Specifying a Caption to a Table in HTML 5

A caption is a short description about a table, which helps you to understand what the table is all about. For example, while creating a student database having details about students, you can specify a caption of the table as Student Details. A caption is specified to a table using the <caption> tag. By default, the caption is aligned in the center of the table.

Let’s do the following steps to specify a caption to a table:


<!DOCTYPE html>
<head>
    <title>Table</title>
</head>
<body bgcolor=”alicablue”>
<table>
<caption>
    <h2>Student Details</h2>
</caption
    <tr>
        <td>Manish Kumar</td>
        <td> 15-03-1983</td>
        <td>Flat No, 303, Shipra Suncity, Ghaziabad</td>
    </tr>
    <tr>
        <td>Rajesh Gupta </td>
        <td>22-02-1984</td>
        <td> H. No.-32, Rajendra Place, New Delhi</td>
    </tr>
    <tr>
        <td>Manisha Dubey </td>
        <td>05-02-1995</td>
        <td> H. No.-125, Patel Nagar, New Delhi</td>
    </tr>
</table
</body>
</html>

Save the document with the name TableCaption.html and open on browser.

add Caption on Table in HTML 5